from django.views import View
from django.shortcuts import render
from django.utils.decorators import method_decorator
from common.views.utils import permission_required,view_logs_required

class LoginView(View):
    """登录页"""
    def get(self, request):
        return render(request, 'login.html')

class IndexView(View):
    """index框架"""
    def get(self, request):
        return render(request, 'index.html')


class AnalysisView(View):
    """首页"""
    @method_decorator(view_logs_required)
    def get(self, request):
        return render(request, 'view/analysis/index.html')

class ConsoleView(View):
    """工作台"""
    @method_decorator(view_logs_required)
    def get(self, request):
        return render(request, 'view/console/index.html')

class UserView(View):
    """用户管理页"""
    @method_decorator(view_logs_required)
    @method_decorator(permission_required('user'))
    def get(self, request):
        return render(request, 'view/admin/user/user.html', {'power':request.powers})

class RoleView(View):
    """角色管理页"""
    @method_decorator(view_logs_required)
    @method_decorator(permission_required('role'))
    def get(self, request):
        return render(request, 'view/admin/role/role.html', {'power':request.powers})

class PowerView(View):
    """权限管理页"""
    @method_decorator(view_logs_required)
    @method_decorator(permission_required('power'))
    def get(self, request):
        return render(request, 'view/admin/power/power.html', {'power':request.powers})

class LogsView(View):
    """日志管理页"""
    @method_decorator(view_logs_required)
    @method_decorator(permission_required('logs'))
    def get(self, request):
        return render(request, 'view/admin/logs/logs.html')